//
//  UIAlertController+Addtions.swift
//  B2BAutoziMall
//
//  Created by heew on 16/4/20.
//  Copyright © 2016年 qeegoo. All rights reserved.
//

import UIKit

extension UIAlertController {

    class func okAndCancelAlert(title: String?,message:String? = "",okaliasTitel:String = "确定",okHandler:((UIAlertAction) -> Void)?) -> UIAlertController {
        let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
        let cancelAction = UIAlertAction(title: "取消", style: .default, handler: nil)
        let okAction = UIAlertAction(title: okaliasTitel, style: .default, handler: okHandler)
        alertController.addAction(cancelAction)
        alertController.addAction(okAction)
        return alertController
    }
    
    class func okAlert(message:String,handler:((UIAlertAction) -> Void)?) -> UIAlertController {
        let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
        let okAction = UIAlertAction(title: "确定", style: .default, handler: handler)
        alertController.addAction(okAction)
        return alertController
    }
    
    class func actionSheet(title:String,titleHandle:((UIAlertAction) -> Void)?) -> UIAlertController {
        let actionSheet = UIAlertController(title: title, message: nil, preferredStyle: .actionSheet)
        actionSheet.addAction(UIAlertAction(title: "确定", style: .default, handler: titleHandle))
        actionSheet.addAction(UIAlertAction(title: "取消", style: .cancel, handler: nil))
        return actionSheet
    }
}
